<?php

 mysql_connect("localhost", "root", "123456") or die(mysql_error()); 
 mysql_select_db("restaurante") or die(mysql_error()); 
 $data = mysql_query("SELECT * FROM rubros") 
 or die(mysql_error()); 

 $output = array();	
 while($info = mysql_fetch_array( $data )) 
 { 
	$output[$info['id']] = $info;
 }
 echo json_encode($output);
 mysql_close();
 
?>